package com.my.basic.flow.basic;

import java.util.concurrent.Flow;

/**
 * @author: marshal
 * @date: 2022-07-27 15:39
 */
public class IntSubscriber implements Flow.Subscriber<Integer> {

    @Override
    public void onSubscribe(Flow.Subscription subscription) {
        subscription.request(10);
    }

    @Override
    public void onNext(Integer item) {
        System.out.println("received data : " + item);
    }

    @Override
    public void onError(Throwable throwable) {
        System.out.println("receive data error : " + throwable.getMessage());
    }

    @Override
    public void onComplete() {
        System.out.println("subscribe complete");
    }
}
